package com.integration.gateway;

import com.integration.gateway.pojo.Delivery;
import com.integration.gateway.pojo.Drink;
import lombok.extern.slf4j.Slf4j;
import org.springframework.integration.aggregator.SimpleSequenceSizeReleaseStrategy;
import org.springframework.integration.annotation.Aggregator;
import org.springframework.integration.annotation.CorrelationStrategy;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.ReleaseStrategy;

import java.util.List;

@Slf4j
//@MessageEndpoint
public class Waiter {

    //@Aggregator(inputChannel = "preparedDrinks", outputChannel = "deliveries")
    public Delivery prepareDelivery(List<Drink> drinks){
        log.info("=== Waiter prepareDelivery ===");
        return  new Delivery(drinks);
    }

    //@CorrelationStrategy
    public int correlateByOrderNumber(Drink drink){
        return drink.getOrderNumber();
    }

    //@ReleaseStrategy
    //SimpleSequenceSizeReleaseStrategy
    public boolean canRelease(List<Drink> drinks){
        return drinks.size() > 0 ;
    }
}
